New signal populate-popup
authorFederico Mena Quintero <federico@gnome.org>
Fri, 14 Dec 2012 17:57:49 +0000 (11:57 -0600)
committerFederico Mena Quintero <federico@gnome.org>
Fri, 14 Dec 2012 17:57:49 +0000 (11:57 -0600)
Instead of conditionally creating contextual menu items like 'Show file properties',
we'll instead let the caller populate the popup menu, as is done for GtkEntry.

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
gtk/gtkplacessidebar.c

index a59da607e24824aa53e5e05b74ca92cee4e6c42b..033fda09171319da8aea80cd4a497ad9d6d3764a 100644 (file)
@@ -148,6 +148,9 @@ struct _GtkPlacesSidebarClass {
        void (* open_location)         (GtkPlacesSidebar *sidebar,
                                        GFile            *location,
                                        GtkPlacesOpenMode open_mode);
+       void (* populate_popup)        (GtkPlacesSidebar *sidebar,
+                                       GtkMenu          *menu,
+                                       GFile            *selected_item);
        void (* show_file_properties)  (GtkPlacesSidebar *sidebar,
                                        GFile            *file);
        void (* empty_trash_requested) (GtkPlacesSidebar *sidebar);
@@ -203,6 +206,7 @@ typedef enum {
 
 enum {
        OPEN_LOCATION,
+       POPULATE_POPUP,
        SHOW_FILE_PROPERTIES,
        EMPTY_TRASH_REQUESTED,
        SHOW_ERROR_MESSAGE,
@@ -308,6 +312,13 @@ emit_open_location (GtkPlacesSidebar *sidebar, GFile *location, GtkPlacesOpenMod
                       location, open_mode);
 }
 
+static void
+emit_populate_popup (GtkPlacesSidebar *sidebar, GtkMenu *menu, GFile *selected_item)
+{
+       g_signal_emit (sidebar, places_sidebar_signals[POPULATE_POPUP], 0,
+                      menu, selected_item);
+}
+
 static void
 emit_show_file_properties (GtkPlacesSidebar *sidebar, GFile *file)
 {
@@ -3704,6 +3715,17 @@ gtk_places_sidebar_class_init (GtkPlacesSidebarClass *class)
                              G_TYPE_OBJECT,
                              GTK_TYPE_PLACES_OPEN_MODE);
 
+       places_sidebar_signals [POPULATE_POPUP] =
+               g_signal_new (I_("populate-popup"),
+                             G_OBJECT_CLASS_TYPE (gobject_class),
+                             G_SIGNAL_RUN_FIRST,
+                             G_STRUCT_OFFSET (GtkPlacesSidebarClass, populate_popup),
+                             NULL, NULL,
+                             _gtk_marshal_VOID__OBJECT_OBJECT,
+                             G_TYPE_NONE, 2,
+                             G_TYPE_OBJECT,
+                             G_TYPE_OBJECT);
+
        places_sidebar_signals [SHOW_FILE_PROPERTIES] =
                g_signal_new (I_("show-file-properties"),
                              G_OBJECT_CLASS_TYPE (gobject_class),